#ifndef _THERMISTOR_H
#define _THERMISTOR_H

#include "settings.h"


class Thermistor {
  private:
    const double v_ref;
    const double r_divider;
    const double r_beta;
    double one_over_beta;
    double one_over_tbeta;
    
    double CToK(double temp_in_C);
    double KtoC(double temp_in_K);
    double KtoF(double temp_in_K);

  public:
    double calc_rthermo(double v_thermistor);
    double calc_temp(double v_thermistor, const bool use_fahrenheit=false);

    Thermistor(double v_ref, 
               double r_divider, 
               double beta, 
               double r_beta, 
               double t_beta) : v_ref(v_ref), 
                                r_divider(r_divider), 
                                // beta(beta), 
                                r_beta(r_beta) {
      t_beta = this->CToK(t_beta);
      this->one_over_beta = 1.0 / beta;
      this->one_over_tbeta = 1.0 / t_beta;
    };
};

#ifdef DEBUG
void test_thermistor(void);
#endif  // DEBUG

#endif //_THERMISTOR_H